package com.hz.house.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.hz.house.dao.CustomerMapper;
import com.hz.house.service.RedisCacheDataService;
import com.hz.house.service.SellManService;

import lombok.extern.slf4j.Slf4j;

/**
 * 项目启动立即执行某些函数
 * 
 * @author lfw
 *
 */
@Component
@Slf4j
public class SpringCommand implements CommandLineRunner{

	@Autowired
	private CustomerMapper userMapper;
	
	@Autowired
	private RedisCacheDataService cacheService;
	
	
	
	@Autowired
	private SellManService sellManService;
	
	@Override
	public void run(String... args) throws Exception {
		 
		//1、查询用户最大id并做系统自增而不是数据库自增
		int maxId = userMapper.getUserMaxId();
		cacheService.setUserMaxId(maxId);
		log.info("首次启动:初始化用户最大id，初始值---"+maxId);
		
		//2、启动访问量常驻线程
		sellManService.startCountWorker();
		
		
	}

	 

}
